package com.pcbly.web.components.utils.jfreechart;

import java.awt.Color;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

public class LineChart  extends AbstractChartFont {
	/**
	 * 构造数据集
	 * 
	 * @return
	 */
	public CategoryDataset getDataSet() {
		DefaultCategoryDataset cateDataset = new DefaultCategoryDataset();
		String str = "××班级平均成绩";
		String s1 = "第一次";
		String s2 = "第二次";
		String s3 = "第三次";
		String s4 = "第四次";
		String s5 = "第五次";
		String s6 = "第六次";
		String s7 = "第七次";
		cateDataset.addValue(70, str, s1);
		cateDataset.addValue(78, str, s2);
		cateDataset.addValue(80, str, s3);
		cateDataset.addValue(66, str, s4);
		cateDataset.addValue(75, str, s5);
		cateDataset.addValue(89, str, s6);
		cateDataset.addValue(61, str, s7);
		return cateDataset;
	}
	/**
	 * 根据数据集创建图表对象
	 * 
	 * @param categoryDataset
	 * @return
	 */
	public  JFreeChart createJFreeChart(CategoryDataset categoryDataset) {
		JFreeChart chart = ChartFactory.createLineChart("××班级平均成绩线状分析图", "考试",
				"成绩(分)", categoryDataset, PlotOrientation.VERTICAL, true, true,
				false);
		this.configFont(chart);
		chart.setBackgroundPaint(Color.WHITE);
		return chart;
	}
	public JFreeChart index(){
		CategoryDataset dataset=getDataSet();
		return createJFreeChart(dataset); 
	}
}
